package org.fast.develop.logicflow.builder;

import lombok.experimental.Tolerate;
import org.fast.develop.logicflow.core.meta.shape.LogicFlowDefinition;
import org.fast.develop.logicflow.core.meta.base.Ref;
import org.fast.develop.logicflow.core.meta.shape.line.SequenceFlow;
import org.fast.develop.logicflow.core.LogicFlowConfiguration;

/**
 * @author 莫寅
 * @createTime 2022-11-25 15:29
 * @desc：
 */
public class SequenceFlowBuilder extends AbstractLogicFlowNodeBuilder<SequenceFlowBuilder, SequenceFlow>{


    @Tolerate
    public SequenceFlowBuilder(LogicFlowDefinition logicFlowDefinition, LogicFlowConfiguration logicFlowConfiguration) {
        super(logicFlowDefinition, logicFlowConfiguration);
    }

    @Override
    protected void postCreateBuilder(SequenceFlow element, AbstractLogicFlowBuilder abstractLogicFlowBuilder){
        Ref targetRef = new Ref();
        targetRef.setResourceId(abstractLogicFlowBuilder.getElement().getResourceId());
        element.setTargetRef(targetRef);

        Ref sourceRef = new Ref();
        sourceRef.setResourceId(abstractLogicFlowBuilder.getPrevAbstractLogicFlowBuilder().getElement().getResourceId());
        element.setSourceRef(sourceRef);
    }

    @Override
    protected Class<SequenceFlow> getElementClass() {
        return SequenceFlow.class;
    }
}
